package com.fare.taluo.core.domain.config.line;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Table;

import com.dayatang.domain.InstanceFactory;
import com.fare.taluo.base.ddd.domain.baseentity.BaseEntity;

@javax.persistence.Entity
@Table(name = "FDC_FREIGHT_PUBLISH")
public class FreightPublishEntity extends BaseEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8275387154218163441L;

	private static FreightPublishEntityRepository repository ;

	
	@Column(name="STANDARD_PRICE")
	private Long standardPrice;

	
	@Column(name="FROM_CITY_NAME")
	private String fromCityName;
   
	@Column(name="TO_CITY_NAME")
	private String toCityName;
	@Column(name="FROM_CITY")
	private String fromCity;
	@Column(name="TO_CITY")
	private String toCity;
	
	private Integer mileage;
	/**
	 * 查找所有公布运价
	 * @return
	 */
	public List<FreightPublishEntity> findAll(){
		return getRepository().findAll();
	}
    
	/**
	 * 删除一个公布运价
	 * @param id
	 */
	public void remove(){
         getRepository().remove(this);
	}
    
	/**
	 * 保存或更新一个公布运价
	 * @param vo
	 */
	public void saveOrUpdate(FreightPublishEntity entity){
		getRepository().saveOrUpdate(entity);
	}
	
	public List<FreightPublishEntity> findFreightPublishByCondition(int pageNum, int pageSize){
		return getRepository().findFreightPublishByCondition(pageNum, pageSize);		
	}
	/**
	 * 根据航线查找运价
	 * 
	 */
	public FreightPublishEntity findByLine(String fromCity,String toCity){
		return getRepository().findByLine(fromCity, toCity);
	}
	
	public static FreightPublishEntityRepository getRepository() {
		if (repository == null) {
			repository = InstanceFactory
					.getInstance(FreightPublishEntityRepository.class);
		}
		return repository;
	}

	public Integer getMileage() {
		return mileage;
	}

	public void setMileage(Integer mileage) {
		this.mileage = mileage;
	}

	public String getFromCityName() {
		return fromCityName;
	}

	public void setFromCityName(String fromCityName) {
		this.fromCityName = fromCityName;
	}

	public String getToCityName() {
		return toCityName;
	}

	public void setToCityName(String toCityName) {
		this.toCityName = toCityName;
	}

	public Long getStandardPrice() {
		return standardPrice;
	}

	public void setStandardPrice(Long standardPrice) {
		this.standardPrice = standardPrice;
	}

	public String getFromCity() {
		return fromCity;
	}

	public void setFromCity(String fromCity) {
		this.fromCity = fromCity;
	}

	public String getToCity() {
		return toCity;
	}

	public void setToCity(String toCity) {
		this.toCity = toCity;
	}
	@Override
	public String toString() {
		return "FreightPublishEntity [standardPrice=" + standardPrice
				+ ", fromCityName=" + fromCityName + ", toCityName="
				+ toCityName + ", fromCity=" + fromCity + ", toCity=" + toCity
				+ ", mileage=" + mileage + "]";
	}
	
	

}
